<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
         <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="0" />    
    <title>栏目列表</title>
</head>
<body>
   
    <div class="container-fluid">
        <div class="line20"></div>    
        <a class="btn btn-primary" href="/cms/article/add">新增栏目</a>
        <div class="line10"></div>
          
        <table class="table table-striped table-hover" border="0" cellpadding="0" cellspacing="0"  id="userTable">
            <thead>
                <tr>
                    <th width="40">ID</th>
                    <th width="200">栏目名称</th>
                    <th width="100">引用</th>
                    <th width="120">排序</th>
                    <th width="100">访问路径</th> 
                     <th width="100">启用</th> 
                    <th width="200">操作</th>                            
                </tr>
            </thead>
            <tbody>
                <td colspan="9">数据加载中……</td>
            </tbody>
        </table>

    
    </div>

   
<link rel="stylesheet" type="text/css" href="/admin/res/style.css">
<link rel="stylesheet" type="text/css" href="/admin/res/index.css">
<script src="/admin/res/jquery.min.js"></script>
<script src="/skin/scripts/bs.min.js"></script>
<script src="/admin/res/cookie.js"></script>
<script src="/admin/res/layindex.js"></script>
    <script type="text/javascript">    
          
       

        $(document).ready(function () {

            var totalpages, totalrecords, pageindex, pagesize, startindex
            ajaxData = {};
            //加载详细列表
            queryUserInfo = function (pageIndex) {              
                ajaxData.pageindex = 1;
                ajaxData.pagesize = 10;
                if (pageIndex && /^\d*$/.test(pageIndex) && pageIndex > 0) {
                    ajaxData.pageindex = pageIndex;
                }
                $.ajax({
                    url: '/cms/node/list',
                    type: 'post',
                    dataType: 'json',
                    data:ajaxData
                })
                .done(function (data) {
                    if (data.length == 0) {
                        return;
                    }
                    var index, tb = $('<tbody></tbody>');
                    totalpages = data.totalpages * 1;
                    totalrecords = data.totalrecords * 1;
                    pageindex = data.pageindex * 1;
                    pagesize = data.pagesize * 1;
                    startindex = (pageindex - 1) * pagesize + 1;
                    for (var i = 0; i < data.length; i++) {
                        index = startindex + i;
                        tb.append($('<tr></tr>')
                            .append('<td>' + data[i].id + '</td>')
                             .append('<td>' + data[i].title + '</td>')
  
                            .append('<td>' + data[i].contact + '</td>')
                              .append('<td>' + data[i].phone + '</td>')
                              .append('<td>' + data[i].tel + '</td>')                            
                            .append('<td>' + data[i].addr + '</td>')
                              .append('<td  class="u-remark">' + data[i].remark + '</td>')
                             .append($('<td></td>')
                                         .append($('<a id="edit" >修改</a>')
                                            .data('content', data[i])
                                        )
                                         .append($('<a id="del">&nbsp;&nbsp; 删除</a>')
                                            .data('content', data[i])
                                        ))                             
                               
                        );
                    }
                    $('#userTable tbody').replaceWith(tb);
                    $('#jump').val(pageindex);
                    $('.u-pager-info').html('共' + totalrecords + '条记录，每页' + pagesize + '条，共' + totalpages + '页，现在是第' + pageindex + '页');

                });
            };

            queryUserInfo();
          

           
            //提示删除
             $("#userTable").on("click", "#del", {}, function (event) {
                 var content = $(this).data('content');
                 if (window.confirm('确定删除 ' + content.title + ' ？')) {
                     ajaxurl('/cms/supply/del/'+content.id, 'post', {_method:'delete'}, function success(data) {
                         if (data.status == 1) {                            
                             queryUserInfo();
                         }
                         else
                             alert(data.msg);
                     });

                 }
                 else
                     return false;

             });

        });
    </script>
</body>
</html>
